public class Demo10 {
	/**
	 * 关于join的说法就是在那个线程中调用，那个线程就要 进行等待
	 * @param args
	 * @throws InterruptedException
	 */
	public static void main(String[] args) throws InterruptedException {
		Thread t1=new Thread(() -> {
			for (int i =0;i<5;i++) {
				System.out.println("线程1开始");
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					throw new RuntimeException(e);
				}
			}
		});
		Thread t2=new Thread(() -> {
			try {
				System.out.println("线程2开始等待");
				t1.join();
			} catch (InterruptedException e) {
				throw new RuntimeException(e);
			}
		});
		t1.start();
		t2.start();
		t2.join();
		System.out.println("主线程结束");
	}
}
